package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.RecordCourse;
import com.xmy.cultivate.entity.StudentGrade;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 学生所在班级与课程（分班表） Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2023-08-17
 */
public interface StudentGradeMapper extends BaseMapper<StudentGrade> {

    @Select("select count(id) as count from student_grade where `status`<>3 and year_part = ${yearPart} and quarter_num = ${quarterNum} and subjects_id=${subjectsId} and reading_status =1 and deleted = 0 and lesson_type = ${lessonType} and student_id = ${studentId}")
    public Integer getStudentStatus(@Param("yearPart") Integer yearPart,@Param("quarterNum") Integer quarterNum,@Param("subjectsId") Long subjectsId,@Param("studentId") Long studentId,@Param("lessonType") Integer lessonType);

    @Select("select sum(use_course_count) as use_course_count from student_grade where deleted = 0 and year_part = ${yearPart} and quarter_num = ${quarterNum} and subjects_id=${subjectsId} and lesson_type = ${lessonType} and student_id = ${studentId}")
    public Integer getUseCourseCount(@Param("yearPart") Integer yearPart,@Param("quarterNum") Integer quarterNum,@Param("subjectsId") Long subjectsId,@Param("lessonType") Integer lessonType,@Param("studentId") Long studentId);

}
